<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>对象字面量增强写法</title>
</head>
<body>
<script>
  const obj = new Object()

  const name = 'why';
  const age = 18;

  // ES5写法

  const obj1 = {
    name: name,
    age: age,
    run: function () {
      console.log("跑步");
    }
  }

  // ES6写法

  const obj2 = {

    // 属性的增强写法
    name,
    age,

    // 方法的增强写法
    run(){
      console.log("跑步");
    }
  }

  console.log(obj1);
  console.log(obj2);
</script>
</body>
</html>
